package com.springboot.test.springbootcrud.dao;

import com.springboot.test.springbootcrud.entity.Department;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.springframework.stereotype.Repository;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2018/12/16 19:59
 */
@Repository
public class DepartmentDao {

    private static final Map<Integer, Department> departmentMap;

    static {
        departmentMap = new HashMap<>();
        departmentMap.put(101, new Department(101, "D-AA"));
        departmentMap.put(102, new Department(102, "D-BB"));
        departmentMap.put(103, new Department(103, "D-CC"));
        departmentMap.put(104, new Department(104, "D-DD"));
        departmentMap.put(105, new Department(105, "D-EE"));
    }

    public Department getDepartment(Integer id) {
        return departmentMap.get(id);
    }

    public Collection<Department> getAllDepartments() {
        return departmentMap.values();
    }

}
